/**
 * 全局对象
 */
 var pb = {
 	toString:function(v) {
 		return Object.prototype.toString.apply(v);
 	},
 	scrollFun:function(){
 		$('.gotoTop').hide();
 		//监听body滚动事件
 		$('.bodyContent').scroll(function(){
 			if($('.bodyContent').scrollTop()>0){
 				$('.gotoTop').show();
 			}else{
 				$('.gotoTop').hide();
 			}
 		});
 			
 		
 	},
 	getQueryString:function(name) { 
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
        var r = window.location.search.substr(1).match(reg); 
        if (r != null) return unescape(r[2]); 
        return null; 
    },
 	gotoTop:function(){
 		$('.bodyContent').animate({scrollTop:0},200);
 	},
 	ajaxPost:function(url,params,successFun,errorFun){
 		$.ajax({
 			type:"POST",
 			//headers:{"Content-Type":"application/json"},
 			dataType:'json',
 			url:url,
 			data:params,//JSON.stringify(params)
 			success:function(r){
 				if(typeof(successFun) === "function"){
 					successFun(r);
 				}
 			},
 			error:function(r){
 				if (typeof(errorFun) === "function") {
 					errorFun(r);
 				}else{
 					alert('后台接口报错');
 				}
 			}
 		});
 	},
 	/*同步ajax*/
 	ajaxPostSyn:function(url,params,successFun,errorFun){
 		$.ajax({
 			type:"POST",
 			headers:{"Content-Type":"application/json"},
 			dataType:'json',
 			url:url+'?dateTime='+new Date().getTime(),
 			async:false,
 			data:JSON.stringify(params),
 			success:function(r){
 				if(typeof(successFun) === "function"){
 					successFun(r);
 				}
 			},
 			error:function(r){
 				if (typeof(errorFun) === "function") {
 					errorFun(r);
 				}else{
 					alert('后台接口报错');
 				}
 			}
 		});
 	},
 	//===============================消息提示
 	alert(msg,t){
 		vm.$message({
 			message:msg,
 			type:t,
 			duration:2500
 		});
 	},
 	alertSuc(msg){
 		pb.alert(msg,"success")
 	},
 	alertErr(msg){
 		pb.alert(msg,"error")
 	},
 	alertWar(msg){
 		pb.alert(msg,"warning")
 	}
 	
 }